#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    vector<string> ret;
    vector<string> binaryTreePaths(TreeNode* root) {
        string pre;
        dfs(root, pre);
        return ret;
    }
    void dfs(TreeNode* root, string pre)
    {
        if (root == nullptr) return;
        pre += to_string(root->val);
        if (root->left == nullptr && root->right == nullptr)
        {
            ret.push_back(pre);
            return;
        }

        pre += "->";

        dfs(root->left, pre);
        dfs(root->right, pre);

        return;

    }
};